<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#assign currentMenu="hotelDictionary"/>
    <#include "../common/header.ftl">
    <script src="/js/plugins/jquery-bootstrap/jquery.bootstrap.min.js"></script>
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>
    <style type="text/css">
        .modal-body {
            max-height: 750px;
            overflow-y: auto;
        }

        .modal-body img {
            width: 100%;
        }
    </style>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-lg-3">
            <#include "../common/menu.ftl">
        </div>
        <div class="col-lg-9">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-head-line">酒店字典目录管理</h1>
                </div>
            </div>

            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="" method="post">
                <input type="hidden" id="currentPage" name="currentPage" value="1">
                <a href="#" class="btn btn-success btn-edit">
                    <span class="glyphicon glyphicon-plus"></span> 添加
                </a>
            </form>
            <table class="table table-striped table-hover" >
                <tr>
                    <th>编号</th>
                    <th>酒店目录编号</th>
                    <th>酒店目录名称</th>
                    <th>酒店目录介绍</th>
                    <th>操作</th>
                </tr>


               <#list result.list as entity >
                   <tr>
                       <td>${entity_index + 1}</td>
                       <td>${entity.sn}</td>
                       <td>${entity.title}</td>
                       <td>${entity.intro}</td>


                       <td>
                           <a class="btn btn-info btn-xs btn-edit" href="#" data-json='${(entity.json)!}'>
                               <span class="glyphicon glyphicon-pencil"></span> 编辑
                           </a>


                           <a class="btn btn-danger btn-xs btn-delete" data-url="/hotelDictionary/delete.do?id=${(entity.id)!}">
                               <span class="glyphicon glyphicon-trash"></span> 删除
                           </a>

                       </td>
                   </tr>
               </#list>

            </table>
            <#include "../common/page.ftl">
        </div>
    </div>
</div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">酒店字典目录编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/hotelDictionary/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden" name="id" value="${(entity.id)!}">
                    <div class="form-group" >
                        <label class="col-sm-3 control-label">酒店字典目录编号：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="sn" value="${(entity.sn)!}"
                                   placeholder="请输入酒店目录编号">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">酒店目录名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="title" value="${(entity.title)!}"
                                   placeholder="请输入酒店目录名称">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">酒店字典目录介绍：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="intro" value="${(entity.intro)!}"
                                   placeholder="请输入酒店目录介绍">
                        </div>
                    </div>


                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary btn-submit">提交</button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        $(".btn-edit").click(function () {
            $("#editForm").get(0).reset();

            var json = $(this).data("json");
            if (json) {
                $("input[name='id']").val(json.id);
                $("input[name='sn']").val(json.sn);
                $("input[name='title']").val(json.title);
                $("input[name='intro']").val(json.intro);
            }
            $("#myModal").modal("show");
        })

        $(".btn-submit").click(function () {
            $("#editForm").ajaxSubmit(function (data) {
                if (data.success) {
                    $.messager.alert("温馨提示","操作成功,2s之后自动刷新");

                    setTimeout(function () {
                        window.location.reload();
                    },2000);

                }else{
                    alert(data.msg);
                }
            })

        })

        $(".btn-delete").click(function () {
            var url = $(this).data("url");
            console.log(url);
            $.messager.confirm("温馨提示","确定要执行删除操作吗?后果请自负",function () {
                $.get(url,function (data) {
                    if (data.success) {
                        $.messager.alert("温馨提示","操作成功,2s之后自动刷新");

                        setTimeout(function () {
                            window.location.reload();
                        },2000);

                    }else{
                        alert(data.msg);
                    }
                })
            })
        })
    })
</script>
</body>
</html>